import fs from 'fs'
import * as Application from 'koa'

const useRoutes = (app: Application) => {
  fs.readdirSync(__dirname).forEach(file => {
    if (file === 'index.ts') { return }
    const route = require(`./${file}`).default
    app.use(route.routes())
    app.use(route.allowedMethods())
  })
}

export default useRoutes